package com.it.test;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@Controller
public class ResponseContextType {


    @RequestMapping("resp")
    public void get(HttpServletResponse response) throws IOException {

        response.setContentType("text/html;charset=utf-8");
        response.getWriter().print("<h1>hello<h1>");

    }


    @RequestMapping(value = "resp2",produces = "text/plain;charset=utf-8")
    @ResponseBody//使返回的值不做视图解析处理，直接响应给浏览器
    public String get() {
        return "<h1>hello<h1>";
    }
}
